﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>ModelHelper类</h3>
    ModelHelper有一个TModel GetModel&lt;TModel>(NFinal.NameValueCollection parameters)方法
    其中TModel是由.net基本类型组成的简单类
    例如：
    <pre class="brush:csharp;">
        public class User
        {
            public int id {get;set;}
            public string name {get;set;}
            public strinig pwd {get;set;}
        }
    </pre>
    TModel类中只能含有由以下类型组成的字段和属性。<br />
    SByte,Byte,Int16,UInt16,Int32,UInt32,Int64,UInt64,Boolean,<br />
    Char,Decimal,Double,Single,DateTime,DateTimeOffset，<br />
    SByte?,Byte?,Int16?,UInt16?,Int32?,UInt32?,Int64?,UInt64?,Boolean?,<br />
    Char?,Decimal?,Double?,Single?,DateTime?,DateTimeOffset?<br /><br />

    NFinal.NameValueCollection属于FastDictionary&lt;string,StringContainer>类型
    使用方式：
    <pre class="brush:csharp;">
        using NFinal;
        public class IndexController : BaseController
        {
            public void Index()
            {
                User user =ModelHelper.GetModel&lt;User>(this.parameters);
                //上面的写法简化为：
                User user1=this.GetModel&lt;User>();
            }
        }
    </pre>
    也可以使用参数的方式：
    <pre class="brush:csharp;">
        using NFinal;
        public class IndexController : BaseController
        {
            public void Index(User user)
            {
                this.Write("Hello ");
                this.Write(user.name);
            }
        }
    </pre>
</body>
</html>